package com.app.utils;

public class Result {
	private Integer code;
	private String msg;
	private Object data;
	
	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}
	
	public static Result returnSuccess() {
		Result result=new Result();
		result.setCode(200);
		return result;
	}
	
	public static Result returnSuccess(Object data) {
		Result result=new Result();
		result.setCode(200);
		result.setData(data);
		return result;
	}
	


	public static Result returnResult(boolean n) {
		return n?Result.returnSuccess():Result.returnError();
	}

	public static Result returnResult(boolean n,String msg) {
		return n?Result.returnSuccess(msg):Result.returnError(msg);
	}
	
	public static Result returnSuccess(String msg) {
		Result result=new Result();
		result.setCode(200);
		result.setMsg(msg);
		return result;
	}
	
	public static Result returnSuccess(Object data,String msg) {
		Result result=new Result();
		result.setCode(200);
		result.setData(data);
		result.setMsg(msg);
		return result;
	}
	
	public static Result returnError() {
		Result result=new Result();
		result.setCode(0);
		return result;
	}
	
	public static Result returnError(String msg) {
		Result result=new Result();
		result.setCode(0);
		result.setMsg(msg);
		return result;
	}
	
	public static Result returnCode(Integer code) {
		Result result=new Result();
		result.setCode(code);
		return result;
	}
	
	public static Result returnCode(Integer code,Object data) {
		Result result=new Result();
		result.setCode(code);
		result.setData(data);
		return result;
	}


}
